home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 31 / Amiga Format CD31 (1998-09-02)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1998-10].iso / -websites- / sasg / dfa / rexx / dfatowtel.lha / dfatowtel.rexx
OS/2 REXX Batch file  |  1995-08-05  |  4KB  |  121 lines

  1. /*************************************************************************
  2.  *  DFAtoWTel.rexx                             by Henning Hucke          *
  3.  *                                                                       *
  4.  *                                                                       *
  5.  *  Convert the DFA-Database into a WilhelmTel-Telephonebook             *
  6.  *                                                                       *
  7.  *  SYNTAX                                                               *
  8.  *      DFAtoWTel FILE/A                                                 *
  9.  *                                                                       *
  10.  *  FUNCTION                                                             *
  11.  *      This script checks all entries of the current DFA data file and  *
  12.  *      writes all entries which contain phonenumbers into the given     *
  13.  *      file conforming the format which is used by the telephonesoft    *
  14.  *      WilhelmTel shiped with the ISDN-Master card of bsc.              *
  15.  *                                                                       *
  16.  *  REQUIREMENTS                                                         *
  17.  *      The only 'requirement' is, that you _must_ mirror the groupnames *
  18.  *      into this script if you change them within DFA.                  *
  19.  *                                                                       *
  20.  *  CONFIGURATION                                                        *
  21.  *      To configure this script to your taste, edit the initialization  *
  22.  *      of the two variables                                             *
  23.  *          GROUPNAME.x - where 1 <= x <= 8. The groupnames you use.     *
  24.  *************************************************************************/
  25.  
  26. /* Presets */
  27.  
  28. RC          = 0
  29. NUMOFGROUPS = 8
  30. NULLCHARS  = '1234567890_.()[]{}/*-+'
  31.  
  32. /*************************************************************************
  33. **  main
  34. */
  35. if ~show(ports, DFA) then
  36. do
  37.     say "Start DFA first."
  38.     exit 0
  39. end
  40.  
  41. options FAILAT 100
  42. options RESULTS
  43.  
  44. PARSE ARG 'FILE 'TelFile
  45.  
  46. /* Open File for write */
  47.  
  48. if ~open(TelBook, TelFile, W) then do
  49.   say '***ERROR: Cant open' TelFile 'for write access!'
  50.   exit 20
  51. end
  52.  
  53. /* Get the names of the groups */
  54.  
  55. counter = 1
  56. do while (RC = 0) & (counter <= NUMOFGROUPS)
  57.   address "DFA" getprefs 'GROUPNAME'||counter
  58.   GROUPNAME.counter = strip(translate(Result,'',NULLCHARS))
  59.   counter = counter + 1
  60. end
  61.  
  62. /* Write out header and group information */
  63.  
  64. call writeln(TelBook, '##')
  65. call writeln(TelBook, '##  WilhelmTel PhoneBook (Generated from DFA-Database by DFAtoWTel)')
  66. call writeln(TelBook, '##  Last Updated on' translate(date(E),'-','/')',' time())
  67. call writeln(TelBook, '##')
  68. call writeln(TelBook, '')
  69. call writeln(TelBook, '')
  70. call writeln(TelBook, '##')
  71. call writeln(TelBook, '##  Phonebook Groups')
  72. call writeln(TelBook, '##')
  73. call writeln(TelBook, '')
  74.  
  75. counter = 1
  76. do while GROUPNAME.counter ~= 'GROUPNAME.'||counter
  77.   call writeln(TelBook, ' GD="'||GROUPNAME.counter||'"')
  78.   counter = counter + 1
  79. end
  80.  
  81. call writeln(TelBook, '')
  82. call writeln(TelBook, '')
  83. call writeln(TelBook, '##')
  84. call writeln(TelBook, '##  PhoneBook Entries')
  85. call writeln(TelBook, '##')
  86. call writeln(TelBook, '')
  87.  
  88. /* Sort entries by name and firstname */
  89.  
  90. address "DFA" sort sort1 NAME sort2 FIRST
  91.  
  92. /* Disable listview refresh of DFAEditor */
  93.  
  94. address "DFA" gui output off input off
  95.  
  96. address "DFA" first stem p.
  97.  
  98. do while RC = 0
  99.     if p.address.10 ~= '' then do
  100.     call writech(TelBook, 'N="'||strip(p.address.1 p.address.2)||'"')
  101.     call writech(TelBook, ' A="'||p.address.4'"')
  102.     call writech(TelBook, ' C="'||strip(p.address.5 p.address.6)||'"')
  103.     call writech(TelBook, ' P="'||p.address.10'"')
  104.     call writech(TelBook, ' G='||p.address.16*2 + p.address.17*4 + p.address.18*8 + p.address.19*16 + p.address.20*32 + p.address.21*64 + p.address.22*128 + p.address.23*256)
  105.     call writech(TelBook, ' F=0')
  106.     call writeln(TelBook, ' COM="'||p.address.15||'"')
  107.     end
  108.  
  109.     address "DFA" next stem p.
  110. end
  111.  
  112. /* Enable listview refresh of DFAEditor */
  113.  
  114. address "DFA" first
  115.  
  116. address "DFA" gui output on input on
  117.  
  118. call close(TelBook)
  119.  
  120. exit 0
  121.